<?php
namespace Topxia\Service\Kuke\Impl;

use Topxia\Common\ArrayToolkit;
use Topxia\Service\Common\BaseService;
use Topxia\Service\Kuke\PromoService;

class PromoServiceImpl extends BaseService implements PromoService
{
	public function getPromo($conditions,$start,$limit)
	{
		return $this->getPromoDao()->getPromo($conditions,$start,$limit);
	}
	public function getMyPromo($userid)
	{
		return $this->getPromoDao()->getMyPromo($userid);
	}
	
	public function getmz($promo)
	{
		return $this->getPromoDao()->getmz($promo);
	}
    public function updatestatus($userid)
	{
		return $this->getPromoDao()->updatestatus($userid);
	}
	public function buildding($conditions)
	{
		return $this->getPromoDao()->buildding($conditions);
	}
	public function getPromoCount($conditions)
	{
		return $this->getPromoDao()->getPromoCount($conditions);
	}
	public function set($conditions)
	{
		return $this->getPromoDao()->set($conditions);
	}
	public function reset($conditions)
	{
		return $this->getPromoDao()->reset($conditions);
	}
	
	public function activing($conditions)
	{
		return $this->getPromoDao()->activing($conditions);
	}

	public function getstatus($Promo)
	{
		return $this->getPromoDao()->getstatus($Promo);
	}

	public function gettrystatus($conditions)
	{
		return $this->getPromoDao()->gettrystatus($conditions);
	}
	
	public function trying($conditions,$ip){
		$user = $this->getUserService()->getUserByLoginField($conditions['xingming']);
		if($user){
			return array("status"=>"err","message"=>"���û��Ѵ���","id"=>3);
		}else{
			$formData = array();
			$formData['email']			= $conditions['email'];
			$formData['mobile']			= $conditions['mobile'];
			$formData['emailOrMobile']	= $conditions['mobile'];
			$formData['nickname']		= $conditions['xingming'];
			$formData['password']		= $conditions['mobile'];
			$formData['type']			= 'Promo';
			$formData['createdIp']		= $ip;
			$this->getAuthService()->register($formData);
		}

		return $this->getPromoDao()->trying($conditions);
	}
	public function getPromoByMachine($conditions){
		return $this->getPromoDao()->getPromoByMachine($conditions);
	}
	public function gettrylist($conditions,$start,$limit){
		return $this->getPromoDao()->gettrylist($conditions,$start,$limit);
	}
	public function gettryCount($conditions)
	{
		return $this->getPromoDao()->gettryCount($conditions);
	}

	protected function getPromoDao()
	{
		return $this->createDao('Kuke.PromoDao');
	}

    protected function getAuthService()
    {
        return $this->createService('User.AuthService');
    }

    protected function getUserService()
    {
        return $this->createService('User.UserService');
    }
}